package com.passive.lock.controller.sys;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.passive.lock.model.vo.TDictVo;
import com.passive.lock.service.DictService;
import com.passive.lock.utils.Config;
import com.passive.lock.utils.ResourcesUtil;
import com.passive.lock.utils.Result;
@Controller
@RequestMapping("di")
public class DictController {
	@Autowired
	private DictService dictService;

	@RequestMapping(value = "/dictChildren")
	@ResponseBody
	public Result dictChildren(@RequestParam Integer id) {

		try {
			Result result = dictService.dictChildren(id);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return Result.build(500, ResourcesUtil.getValue(Config.MESSAGE, "500"));
		}
	}

	@RequestMapping(value = "/dictlist")
	@ResponseBody
	public Result dictList() {
		try {
			Result result = dictService.dictList();
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return Result.build(500, ResourcesUtil.getValue(Config.MESSAGE, "500"));
		}
	}
	
	@RequestMapping(value = "/adddict")
	@ResponseBody
	public Result addDict(@RequestBody TDictVo tDictVo) {
		try {
			Result result = dictService.addDict(tDictVo);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return Result.build(500, ResourcesUtil.getValue(Config.MESSAGE, "500"));
		}
	}

	@RequestMapping(value = "/updatedict")
	@ResponseBody
	public Result updateDict(@RequestBody TDictVo tDictVo) {
		try {
			Result result = dictService.updateDict(tDictVo);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return Result.build(500, ResourcesUtil.getValue(Config.MESSAGE, "500"));
		}
	}

	@RequestMapping(value = "/deletedict")
	@ResponseBody
	public Result deleteDict(@RequestBody TDictVo tDictVo) {
		try {
			Result result = dictService.deleteDict(tDictVo);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return Result.build(500, ResourcesUtil.getValue(Config.MESSAGE, "500"));
		}
	}
}
